/*
 * Copyright 2018-2019 KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain menu_text_color copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.wanchuang.hepos.bridge.request;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.wanchuang.hepos.bridge.data.repository.HttpRequestManager;
import com.wanchuang.hepos.proto.Area;
import com.wanchuang.hepos.proto.Bank;
import com.wanchuang.hepos.proto.LoginOuterClass;
import com.wanchuang.hepos.proto.MemberBank;
import com.wanchuang.hepos.proto.MemberOuterClass;
import com.wanchuang.hepos.proto.Merchantservice;

import java.util.List;

/**
 * 音乐资源  RequestViewModel
 * <p>
 * TODO tip：RequestViewModel 通常按业务划分
 * 一个项目中通常存在多个 RequestViewModel
 * 对 Jetpack ViewModel 的知识点感兴趣可详见 https://xiaozhuanlan.com/topic/6257931840
 * <p>
 * Create by KunMinX at 19/10/29
 */
public class LoginRequestViewModel extends ViewModel {

    private MutableLiveData<String> errorString;  // 错误信息的返回
    private MutableLiveData<String> resultString;  // 忘记密码成功
    private MutableLiveData<String> formToken;  // 忘记密码成功
    private MutableLiveData<String> CodeString;  // 获取验证码成功
    private MutableLiveData<String> compathone;  // 上传图片第一步
    private MutableLiveData<String> compathTwo;  // 上传图片第二步
    private MutableLiveData<String> compathThree;  // 上传图片第三步
    private MutableLiveData<List<Merchantservice.mcc>> MccArray;  // 获取得mcc数组
    private MutableLiveData<List<Area.area>> areas;  // 获取得mcc数组
    private MutableLiveData<List<MemberBank.bank>> banks;  // 获取支持银行卡
    private MutableLiveData<Merchantservice.credit_card> credit_card;  // 获取支持银行卡
    private MutableLiveData<MemberOuterClass.Member> member;  //  获取代理信息接口




    private MutableLiveData<LoginOuterClass.Login> loginLiveData;  // 登录解析数据的返回



    public MutableLiveData<LoginOuterClass.Login> getLoginLiveData() {
        if (loginLiveData == null) {
            loginLiveData = new MutableLiveData<>();
        }
        return loginLiveData;
    }



    public MutableLiveData<String> getCodeString() {
        if (CodeString == null) {
            CodeString = new MutableLiveData<>();
        }
        return CodeString;
    }

    public MutableLiveData<String> getFormToken() {
        if (formToken == null) {
            formToken = new MutableLiveData<>();
        }
        return formToken;
    }



    public MutableLiveData<String> getErrorString() {
        if (errorString == null) {
            errorString = new MutableLiveData<>();
        }
        return errorString;
    }


    public MutableLiveData<String> getResultString() {
        if (resultString == null) {
            resultString = new MutableLiveData<>();
        }
        return resultString;
    }

    public MutableLiveData<String> getCompathone() {
        if (compathone == null) {
            compathone = new MutableLiveData<>();
        }
        return compathone;
    }

    public MutableLiveData<String> getCompathTwo() {
        if (compathTwo == null) {
            compathTwo = new MutableLiveData<>();
        }
        return compathTwo;
    }

    public MutableLiveData<String> getCompathThree() {
        if (compathThree == null) {
            compathThree = new MutableLiveData<>();
        }
        return compathThree;
    }

    public MutableLiveData<List<Merchantservice.mcc>> getMccArray()
    {
        if (MccArray == null) {
            MccArray = new MutableLiveData<>();
        }
        return MccArray;
    }

    public MutableLiveData<List<Area.area>> getAreas()
    {
        if (areas == null) {
            areas = new MutableLiveData<>();
        }
        return areas;
    }
    public MutableLiveData<List<MemberBank.bank>> getBanks()
    {
        if (banks == null) {
            banks = new MutableLiveData<>();
        }
        return banks;
    }

    public MutableLiveData<Merchantservice.credit_card> getCredit_card()
    {
        if (credit_card == null) {
            credit_card = new MutableLiveData<>();
        }
        return credit_card;
    }
    public MutableLiveData<MemberOuterClass.Member> getMember()
    {
        if (member == null) {
            member = new MutableLiveData<>();
        }
        return member;
    }


    public void requestLogin(String userName,String password,String formToken) {
        HttpRequestManager.getInstance().login(loginLiveData,getErrorString(),userName,password,formToken);
    }

    public void forgetPassword(String phone,String code,String password,String formToken) {
        HttpRequestManager.getInstance().forgetPassword(getResultString(), getErrorString(),phone,password,code,formToken);
    }

    public void getCode(String phone,String type) {
        HttpRequestManager.getInstance().getCode(getCodeString(), getErrorString(),phone,type);
    }

    public void register(String phone,String code,String password,String snCode,String formToken) {
        HttpRequestManager.getInstance().register(getResultString(), getErrorString(),phone,password,code,snCode,formToken);
    }

    public void upLoadImage(String path,MutableLiveData<String> resultString) {
        HttpRequestManager.getInstance().upLoadImage(resultString, getErrorString(),path);
    }

    public void intent(String uploadPath, String uploadPathTwo, String uploadPaththree, String name, String qrcode) {
        HttpRequestManager.getInstance().intent(getResultString(), getErrorString(),uploadPath,uploadPathTwo,uploadPaththree,name,qrcode);
    }
    public void getmcc(String searchName) {
        HttpRequestManager.getInstance().getmcc(getMccArray(), getErrorString(),searchName);
    }

    public void area_list(String area_id) {
        HttpRequestManager.getInstance().area_list(getAreas(), getErrorString(),area_id);
    }


    public void modify_mcc(String name, String mccCode, String provinceCode, String cityCode, String areaCode, String mccDetailAdree) {
        HttpRequestManager.getInstance().modify_mcc(getResultString(), getErrorString(),name,mccCode,provinceCode,cityCode,areaCode,mccDetailAdree);
    }

    public void audit(String uploadPath, String uploadPathTwo, String uploadPathThree, String name,
                      String bankCardCode, String phone, String code) {
        HttpRequestManager.getInstance().audit(getResultString(), getErrorString(),uploadPath,uploadPathTwo,uploadPathThree,name,bankCardCode,phone,code);

    }

    public void get_support(String type, String form) {
        HttpRequestManager.getInstance().get_support(getBanks(), getErrorString(),type,form);
    }

    public void face_check(String idCardFront) {
        HttpRequestManager.getInstance().face_check(getResultString(), getErrorString(),idCardFront);
    }


    public void credit_send(String name, String card, String valid_time, String cvv, String mobile) {
        HttpRequestManager.getInstance().credit_send(getCredit_card(), getErrorString(),name,card,valid_time,cvv,mobile);
    }


    public void creditCard(String name, String card, String valid_time, String cvv, String mobile, String orderId, String captcha) {
        HttpRequestManager.getInstance().creditCard(getResultString(),getErrorString(),name,card,valid_time,cvv,mobile,orderId,captcha);
    }

    public void bind(String snCode) {
        HttpRequestManager.getInstance().bind(getResultString(),getErrorString(),snCode);
    }

    public void getMemberInfo() {
        HttpRequestManager.getInstance().get_member_info(getMember(),getErrorString());
    }


    public void getSendcode(String mPhone, String bankCardCode) {
        HttpRequestManager.getInstance().send_code(getCodeString(),getErrorString(),mPhone,bankCardCode);
    }

    public void get_form_token(String action) {
        HttpRequestManager.getInstance().GetFormToken(action,getFormToken(),getErrorString());
    }
}
